//
//  UIBarButtonItem+Extension.swift
//  HotNews
//
//  Created by yang on 2017/9/23.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

import Foundation

extension UIBarButtonItem
{
    
    /// UIBarButtonItem
    ///
    /// - Parameters:
    ///   - title: 文字
    ///   - fontSize: 字体大小
    ///   - target: 目标
    ///   - action: 事件
    convenience init(title: String, fontSize: CGFloat = 16, target: Any?, action: Selector, isBack: Bool = false)
    {
        let btn = UIButton(title: title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.RGBColor(red: 20, green: 82, blue: 184), target: target, action: action, backgroundImageName: nil)
        if isBack
        {
            let imageName = "navigationbar_back_withtext"
            
            btn.setImage(UIImage(named: imageName), for: .normal)
            btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        
        self.init(customView: btn)
    }
}
